package simorg.actions;


import java.util.ArrayList;

import org.dom4j.Document;

import simorg.security.AccessBarrier;
import simorg.security.AdminAccess;
import simorg.view.ModelView;
import simorg.view.WebSessionContext;

public abstract class Action {
	protected String errorMessage;
	protected String name;
	protected String controllerName = null;
	protected ArrayList<String> requestArgs;
	
	
	public Action(String name) {
		this.name = name;
		this.requestArgs = new ArrayList<String>();
	}
	
	public ArrayList<String> getRequestArgs() {
		return requestArgs;
	}

	public void setRequestArgs(ArrayList<String> requestArgs) {
		this.requestArgs = requestArgs;
	}

	public String getName() {
		return name;
	}
	
	
	
	public String getControllerName() {
		return controllerName;
	}

	public abstract ModelView process(WebSessionContext wc) throws Exception ;
	
	public ModelView checkAccess(WebSessionContext wc) throws Exception {
		return null;
	}
	
	public Document getBaseXml(WebSessionContext wc) {
		return wc.buildBaseXml();
	}
	
	protected ModelView checkAdminAccess(WebSessionContext wc) throws Exception {
		AccessBarrier ab = new AccessBarrier();
		ab.addSecurityAccess(new AdminAccess(wc));
		return ab.process(wc);
	}
	
	
}
